import * as echarts from 'echarts'

const makeScatterOption = (): echarts.EChartsCoreOption => {
  const color = '#ff0000'
  const xName = 'Position [m]'
  const xScope = [0, 1]
  const xSplitNumber = 10
  const yScope = [1.18, 1.32]
  const ySplitNumber = 14
  const data = [
    [0, 1.3],
    [0.001, 1.298],
    [0.001, 1.29],
    [0.005, 1.268],
    [0.01, 1.258],
    [0.01, 1.258],
    [0.2, 1.22],
    [0.3, 1.24],
    [0.4, 1.26],
    [0.5, 1.28]
  ]
  return {
    color: color,
    xAxis: {
      name: xName,
      nameLocation: 'middle',
      nameTextStyle: {
        fontWeight: 'bold',
        fontSize: 18
      },
      nameGap: 40,
      min: xScope[0],
      max: xScope[1],
      splitNumber: xSplitNumber,
      axisTick: {
        alignWithLabel: true,
        length: 6
      },
      splitLine: {
        show: false
      },
      axisLabel: {
        margin: 15
      }
    },
    yAxis: {
      type: 'value',
      axisTick: {
        alignWithLabel: true,
        length: 8
      },
      axisLabel: {
        formatter: (value: number, index: number) => {
          if (index % 2 === 0) {
            return value.toExponential(2)
          } else {
            return ''
          }
        },
        margin: 15
      },
      min: yScope[0],
      max: yScope[1],
      splitNumber: ySplitNumber,
      splitLine: {
        show: false
      }
    },
    series: [
      {
        type: 'scatter',
        data: data
      }
    ]
  }
}

export default makeScatterOption